package com.fusion.ui.windows;

import com.fusion.ui.UISubsystem;
import com.stendahls.XUI.XUIDialog;
import com.stendahls.nif.ui.OptionDialog;
import com.stendahls.ui.JHtmlLabel;

import javax.swing.*;



/**
 * @author SwethaShivakumar 
 * Project: fusion
 * Date: Mar 12, 2009
 * URL: http://fusionwiki.co.cc
 * Mail Me At: shiva@fusionproject.co.cc
 */
public class ConnectedToNewFriendDialog extends XUIDialog {

	private static final long serialVersionUID = 1L;

	public ConnectedToNewFriendDialog(UISubsystem ui, JFrame f, String name) throws Exception {
        super(ui.getRl(), ui.getRl().getResourceStream("xui/newfriendconnection.xui.xml"), f, true);
        ((JHtmlLabel)xui.getComponent("label")).replaceString("$$NAME$$", name);
        ui.getMainWindow().setConnectedToNewFriendDialogShowing(true);
        display();
        JCheckBox cb = (JCheckBox) xui.getComponent("dontshow");
        if (cb.isSelected()) {
            if (OptionDialog.showQuestionDialog(this, "Next time a new friends connects to you no message will be shown. You will also automatically connect to all friends of the new friend. Is this what you want?")) {
                ui.getCore().getSettings().getInternal().setAlwaysautomaticallyconnecttoallfriendsoffriend(1);
            }
        }
        ui.getMainWindow().setConnectedToNewFriendDialogShowing(false);
    }
}
